// @algorithm @lc id=100284 lang=cpp
// @title jian-sheng-zi-lcof

#include "algm/algm.h"
#include <iostream>
#include <string>
#include <vector>
using namespace std;
class Solution {
public:
    // dp做法
    /* int cuttingRope(int n) {
        vector<int> dp(n + 1, 0);
        dp[1] = 0;
        for (int i = 2; i <= n; ++i) {
            for (int j = 1; j <= i / 2 + 1; ++j) {
                dp[i] = max(dp[i], j * (i - j));
                dp[i] = max(dp[i], j * dp[i - j]);
            }
        }
        return dp[n];
    } */

    // 贪心
    int cuttingRope(int n) {
        if (n < 2) {
            return 0;
        }
        if (n == 2) {
            return 1;
        }
        if (n == 3) {
            return 2;
        }
        int timesOf3 = n / 3;
        if (n - timesOf3 * 3 == 1) {
            timesOf3 -= 1;
        }
        int timesOf2 = (n - timesOf3 * 3) / 2;
        return (int)(pow(3, timesOf3)) * (pow(2, timesOf2));
    }
};